﻿using System;
using MyUtils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Test.MyUtils.TestHelp;

namespace Test.MyUtils
{
	[TestClass]
	public class TestWorks : FixtureMsTest
	{
		[TestMethod]
		public void Should_create_asynchron_work()
		{
			var q = 0;
			var work = new Work("test1", delegate { q++; })
			{
				SleepBetweenActs = TimeSpan.FromMilliseconds(300),
				SleepOnStartRandom = TimeSpan.Zero,
			};
			work.Start();

			Wait(() => q == 1);
			Wait(() => q == 2);
			Wait(() => q == 3);

			work.Stop();
		}
	}
}